package com.kitty.game.rank.facade;

import com.kitty.common.cache.RedisService;
import com.kitty.game.achieve.common.SendAchieve;
import com.kitty.game.enter.FiedValue;
import com.kitty.game.enter.RespUpdate;
import com.kitty.game.rank.model.record.*;
import com.kitty.game.rank.service.handler.*;
import com.kitty.game.role.service.RoleService;
import com.kitty.game.task.service.taskHandler.RoleZhengDaoTaskHandler;
import com.kitty.listener.event.*;
import com.kitty.mina.cache.DataCache;
import com.kitty.mina.message.MessagePusher;
import org.apache.mina.core.session.IoSession;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.enter.TitleInfo;
import com.kitty.game.equip.model.RoleEquip;
import com.kitty.game.party.model.Party;
import com.kitty.game.pet.model.Pet;
import com.kitty.game.rank.message.ReqCrossRankView;
import com.kitty.game.rank.service.RankService;
import com.kitty.game.role.model.Role;
import com.kitty.game.utils.Const;
import com.kitty.game.welfare.model.CommonFetchedData;
import com.kitty.listener.EventType;
import com.kitty.listener.annotation.EventHandler;
import com.kitty.mina.annotation.RequestMapping;
import com.kitty.mina.cache.SessionUtils;

import java.util.ArrayList;
import java.util.List;

@Controller
public class RankController {

    @Autowired
    private Dao dao;
    @Autowired
    RedisService redisService;
	
	//k-20200729-01 称号 +500万金元宝
    //一马当先：等级第一个到达85级的
    //道心稳固：道行第一个到达3000年
    //万夫莫开：第一个物理伤害到达8w
    //无法无天：第一个法伤到达6w
    //风驰电掣：第一个速度到达6000
    /** 缓存称号 **/
    public static String FIRST_TITLES ="";

    private static int number = 50000;
    private static String rankRewardtype = "";
    /** 初始化**/
    public void loadCommonSet() {
        CommonFetchedData commonFetchedData = dao.fetch(CommonFetchedData.class, "first_titles");
        //初始化
        if(commonFetchedData==null){
            commonFetchedData =new CommonFetchedData("first_titles","");
            dao.insert(commonFetchedData);
        }else {
            FIRST_TITLES = commonFetchedData.getData();
        }
        String rewardType = DataCache.REDIS_DATA.get("first_title_reward");
        rankRewardtype = rewardType.split("-")[0];
        number = Integer.parseInt(rewardType.split("-")[1]);

    }

    /**
     * 称号已获得状态 存到数据库
     */
    public void updateFirstTitle(){
        dao.update(CommonFetchedData.class, Chain.make("data",FIRST_TITLES),Cnd.where("type","=","first_titles"));
    }
    
    /**升级时处理排行榜相关内容*/
    @EventHandler(EventType.ROLE_LEVEL_UP)
    public void handleRoleLevelUpEvent(RoleLevelUpEvent roleLevelUpEvent) {
        Role role = roleLevelUpEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        short level = roleLevelUpEvent.getLevel();
        SpringUtils.getBean(SendAchieve.class).achieveRoleLevelUpEvent(roleLevelUpEvent);


        SpringUtils.getBean(RoleLevelRankHandler.class).update(role.getGid(), new RoleLevelRankRecord(role.getGid(), level, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon()));

        /**升级时还需要处理跨越等级段的排行榜，从之前等级段删除，加入到新的等级段*/
        SpringUtils.getBean(TaoRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(MonthTaoRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(ZhengDaoRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(TowerRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(YingXiongRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(PhyPowerRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(MagPowerRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(SpeedRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
        SpringUtils.getBean(DefenseRankHandler.class).handleRoleUpgrade(role, roleLevelUpEvent.getOldLevel(), roleLevelUpEvent.getLevel());
   
        if((!FIRST_TITLES.contains("一马当先"))&&level>=85){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("一马当先");
            titleInfo.setTitle("一马当先");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            FIRST_TITLES=FIRST_TITLES+"一马当先:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个到达#Y 85#n级，获得#Y一马当先#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }

    /**道行改变时处理排行榜相关内容*/
    @EventHandler(EventType.TAO_CHANGE)
    public void handleTaoChangeEvent(TaoChangeEvent taoChangeEvent) {
        Role role = taoChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int tao = taoChangeEvent.getTao();
        SpringUtils.getBean(SendAchieve.class).achieveRoleTaoEvent(taoChangeEvent);
        TaoRankHandler taoRankHandler = SpringUtils.getBean(TaoRankHandler.class);
        String range = taoRankHandler.getLevelRange(role);
        SpringUtils.getBean(RoleZhengDaoTaskHandler.class).handleRoleTaoUp(role,tao);
        if (range != null) {
            taoRankHandler.update(range, role.getGid(),new TaoRankRecord(role.getGid(), tao, role.getTaoLastPoint(),role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));
        }
      //手动升到8000年得到的数据。。。。。
        if((!FIRST_TITLES.contains("道法稳固"))&&tao>=2880000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("道法稳固");
            titleInfo.setTitle("道法稳固");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"道法稳固:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个道行到达#Y 8000#n年，获得#Y道法稳固#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
        if((!FIRST_TITLES.contains("万道归一·金"))&&tao>=3600000 && role.getPolar() == 1){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("万道归一·金");
            titleInfo.setTitle("万道归一·金");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"万道归一·金:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n金系第一个道行到达#Y 10000#n年，获得绝版唯一称号#Y万道归一·金#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
        if((!FIRST_TITLES.contains("万道归一·木"))&&tao>=3600000 && role.getPolar() == 2){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("万道归一·木");
            titleInfo.setTitle("万道归一·木");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"万道归一·木:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n木系第一个道行到达#Y 10000#n年，获得绝版唯一称号#Y万道归一·木#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
        if((!FIRST_TITLES.contains("万道归一·水"))&&tao>=3600000 && role.getPolar() == 3){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("万道归一·水");
            titleInfo.setTitle("万道归一·水");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"万道归一·水:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n水系第一个道行到达#Y 10000#n年，获得绝版唯一称号#Y万道归一·水#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
        if((!FIRST_TITLES.contains("万道归一·火"))&&tao>=3600000 && role.getPolar() == 4){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("万道归一·火");
            titleInfo.setTitle("万道归一·火");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"万道归一·火:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n火系第一个道行到达#Y 10000#n年，获得绝版唯一称号#Y万道归一·火#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }

        if((!FIRST_TITLES.contains("万道归一·土"))&&tao>=3600000 && role.getPolar() == 5){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("万道归一·土");
            titleInfo.setTitle("万道归一·土");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"万道归一·土:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n土系第一个道行到达#Y 10000#n年，获得绝版唯一称号#Y万道归一·土#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }

    /**月道行改变时处理排行榜相关内容*/
    @EventHandler(EventType.MONTH_TAO_CHANGE)
    public void handleMonthTaoChangeEvent(MonthTaoChangeEvent monthTaoChangeEvent) {
        Role role = monthTaoChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int tao = monthTaoChangeEvent.getTao();
        SpringUtils.getBean(SendAchieve.class).achieveRoleMonthTaoEvent(monthTaoChangeEvent);
        MonthTaoRankHandler monthTaoRankHandler = SpringUtils.getBean(MonthTaoRankHandler.class);
        String range = monthTaoRankHandler.getLevelRange(role);

        if (range != null) {
            monthTaoRankHandler.update(range, role.getGid(), new TaoRankRecord(role.getGid(), tao, role.getMonthTaoLastPoint(), role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));
        }
    }

    /**战力改变时处理排行榜相关内容*/
    @EventHandler(EventType.ZHAN_LI_CHANGE)
    public void handleZhanLiChangeEvent(ZhanLiChangeEvent zhanLiChangeEvent) {
        Role role = zhanLiChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        role.setfight_cap(zhanLiChangeEvent.getZhanLi());
        role.setFight_cap_total(zhanLiChangeEvent.getZhanLi()*2);
        //更新战力
        RespUpdate respUpdate = new RespUpdate();
        List<FiedValue> listUpdate1 = new ArrayList();
        listUpdate1.add(new FiedValue(493, 3,zhanLiChangeEvent.getZhanLi()));
        listUpdate1.add(new FiedValue(500, 3,role.getfight_cap_total()));
        respUpdate.setList(listUpdate1);
        MessagePusher.pushMessage(role, respUpdate);

        int zhanli = zhanLiChangeEvent.getZhanLi();
        ZhanLiRankHandler zhanLiRankHandler = SpringUtils.getBean(ZhanLiRankHandler.class);
        String range = zhanLiRankHandler.getLevelRange(role);
        if (range != null) {
            zhanLiRankHandler.update(range,role.getGid(), new ZhanLiRankRecord(role.getGid(), zhanli, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));
        }
        if((!FIRST_TITLES.contains("巅峰战力"))&&zhanli>=1000000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("巅峰战力");
            titleInfo.setTitle("巅峰战力");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"巅峰战力:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个战力到达#Y 1000000#n，获得#巅峰战力#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
        if(zhanli>=100000){
            SpringUtils.getBean(RoleService.class).addAchieveScore(role,"107003");
        }
        if(zhanli>=300000){
            SpringUtils.getBean(RoleService.class).addAchieveScore(role,"107001");
        }
        if(zhanli>=500000){
            SpringUtils.getBean(RoleService.class).addAchieveScore(role,"107002");
        }
        if(zhanli>=1000000){
            SpringUtils.getBean(RoleService.class).addAchieveScore(role,"107004");
        }
    }

    /**物理伤害改变时处理排行榜相关内容*/
    @EventHandler(EventType.PHY_POWER_CHANGE)
    public void handlePhyPowerChangeEvent(PhyPowerChangeEvent phyPowerChangeEvent) {
        Role role = phyPowerChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int phyPower = phyPowerChangeEvent.getPhyPower();
        PhyPowerRankHandler phyPowerRankHandler = SpringUtils.getBean(PhyPowerRankHandler.class);
        String range = phyPowerRankHandler.getLevelRange(role);
        if (range != null) {
            phyPowerRankHandler.update(range,role.getGid(), new PhyPowerRankRecord(role.getGid(), phyPower, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));

        }
        if((!FIRST_TITLES.contains("力敌千钧"))&&phyPower>=80000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("力敌千钧");
            titleInfo.setTitle("力敌千钧");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"力敌千钧:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个物伤到达#Y 80000#n，获得#力敌千钧#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }

    /**法术伤害改变时处理排行榜相关内容*/
    @EventHandler(EventType.MAG_POWER_CHANGE)
    public void handleMagPowerChangeEvent(MagPowerChangeEvent magPowerChangeEvent) {
        Role role = magPowerChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int magPower = magPowerChangeEvent.getMagPower();
        MagPowerRankHandler magPowerRankHandler = SpringUtils.getBean(MagPowerRankHandler.class);
        String range = magPowerRankHandler.getLevelRange(role);
        if (range != null) {
            magPowerRankHandler.update(range,role.getGid(), new MagPowerRankRecord(role.getGid(), magPower, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));
        }

        if((!FIRST_TITLES.contains("法力无边"))&&magPower>=60000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("法力无边");
            titleInfo.setTitle("法力无边");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"法力无边:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个法伤到达#Y 60000#n，获得#法力无边#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }

    /**防御改变时处理排行榜相关内容*/
    @EventHandler(EventType.DEFENSE_CHANGE)
    public void handleDefensChangeEvent(DefenseChangeEvent defenseChangeEvent) {
        Role role = defenseChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int defense = defenseChangeEvent.getDefense();
        DefenseRankHandler defenseRankHandler = SpringUtils.getBean(DefenseRankHandler.class);
        String range = defenseRankHandler.getLevelRange(role);
        if (range != null) {
            defenseRankHandler.update(range,role.getGid(), new DefenseRankRecord(role.getGid(), defense, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));
        }
        if((!FIRST_TITLES.contains("铜墙铁壁"))&&defense>=80000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("铜墙铁壁");
            titleInfo.setTitle("铜墙铁壁");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"铜墙铁壁:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个防御到达#Y 80000#n，获得#R铜墙铁壁#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }

    /**速度改变时处理排行榜相关内容*/
    @EventHandler(EventType.SPEED_CHANGE)
    public void handleSpeedChangeEvent(SpeedChangeEvent speedChangeEvent) {
        Role role = speedChangeEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        int speed = speedChangeEvent.getSpeed();
        SpeedRankHandler speedRankHandler = SpringUtils.getBean(SpeedRankHandler.class);
        String range = speedRankHandler.getLevelRange(role);
        if (range != null) {
            speedRankHandler.update(range,role.getGid(), new SpeedRankRecord(role.getGid(), speed, role.getPartyName(), role.getName(), role.getPolar(), role.getRoleIcon(), role.getLevel()));

        }
        if((!FIRST_TITLES.contains("风驰电掣"))&&speed>=8000){
            TitleInfo titleInfo = new TitleInfo();
            titleInfo.setType("风驰电掣");
            titleInfo.setTitle("风驰电掣");
            SpringUtils.getRoleService().addTitle(role, titleInfo);
            //SpringUtils.getBean(PayService.class).jifen(role, score);
            SpringUtils.getRoleService().addCountByteType(role,number,rankRewardtype);
            FIRST_TITLES=FIRST_TITLES+"风驰电掣:"+role.getName()+",";
            SpringUtils.getChatService().sendAdnotice("恭喜玩家#R" + role.getName() + "#n第一个速度到达#Y 8000#n，获得#R风驰电掣#n的称号,奖励#R"+number+"#n"+rankRewardtype);
            updateFirstTitle();
        }
    }


    /**宠物武学改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_MARTIAL_CHANGE)
    public void handlePetMartialChangeEvent(PetMartialChangeEvent petMartialChangeEvent) {
        Pet pet = petMartialChangeEvent.getPet();
        int value = petMartialChangeEvent.getMartial();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_MARTIAL, pet, value);
    }

    /**宠物武学改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_MONTH_MARTIAL_CHANGE)
    public void handlePetMonthMartialChangeEvent(PetMonthMartialChangeEvent petMonthMartialChangeEvent) {
        Pet pet = petMonthMartialChangeEvent.getPet();
        int value = petMonthMartialChangeEvent.getMartial();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_MONTH_MARTIAL, pet, value);
    }

    /**宠物物理伤害改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_PHY_POWER_CHANGE)
    public void handlePetPhyPowerChangeEvent(PetPhyPowerChangeEvent petPhyPowerChangeEvent) {
        Pet pet = petPhyPowerChangeEvent.getPet();
        int value = petPhyPowerChangeEvent.getPhyPower();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_PHY_POWER, pet, value);
    }

    /**宠物法术伤害改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_MAG_POWER_CHANGE)
    public void handlePetMagPowerChangeEvent(PetMagPowerChangeEvent petMagPowerChangeEvent) {
        Pet pet = petMagPowerChangeEvent.getPet();
        int value = petMagPowerChangeEvent.getMagPower();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_MAG_POWER, pet, value);
    }

    /**宠物防御改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_DEFENSE_CHANGE)
    public void handlePetDefenseChangeEvent(PetDefenseChangeEvent petDefenseChangeEvent) {
        Pet pet = petDefenseChangeEvent.getPet();
        int value = petDefenseChangeEvent.getDefense();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_DEFENSE, pet, value);
    }

    /**宠物速度改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_SPEED_CHANGE)
    public void handlePetSpeedChangeEvent(PetSpeedChangeEvent petSpeedChangeEvent) {
        Pet pet = petSpeedChangeEvent.getPet();
        int value = petSpeedChangeEvent.getSpeed();
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_SPEED, pet, value);
    }
    /**宠物战力改变时处理排行榜相关内容*/
    @EventHandler(EventType.PET_ZHANLI_CHANGE)
    public void handlePetZhanLiChangeEvent(PetZhanLiChangeEvent petZhanLiChangeEvent) {
        Pet pet = petZhanLiChangeEvent.getPet();
        int value = petZhanLiChangeEvent.getZhanli();
        pet.setFight_cap(value);
        RespUpdate respUpdate = new RespUpdate();
        List<FiedValue> list = new ArrayList<>();
        list.add(new FiedValue(493, 3,value));
        respUpdate.setRoleId(pet.getId());
        respUpdate.setList(list);
        MessagePusher.pushMessage(petZhanLiChangeEvent.getRole(), respUpdate);
        SpringUtils.getBean(PetRankHandler.class).update(Const.RANK_PET_ZHANLI, pet, value);
    }

    /**装备改造等级改变时处理排行榜相关内容*/
    @EventHandler(EventType.EQUIP_UPGRADE_LEVEL_CHANGE)
    public void handleEquipUpgradeLevelChangeEvent(EquipUpgradeLevelChangeEvent equipUpgradeLevelChangeEvent) {
        Role role = equipUpgradeLevelChangeEvent.getRole();
        RoleEquip roleEquip = equipUpgradeLevelChangeEvent.getRoleEquip();
        short prevValue = equipUpgradeLevelChangeEvent.getPrevUpgradeLevlel();
        short value = equipUpgradeLevelChangeEvent.getUpgradeLevlel();
        SpringUtils.getBean(SendAchieve.class).handleEquipChangeAchieveEvent(equipUpgradeLevelChangeEvent);
        SpringUtils.getBean(EquipRankHandler.class).updateUpgradeLevelChange(role, roleEquip, prevValue, value);
        //发送成就
    }


    /**装备完美度改变时处理排行榜相关内容*/
    @EventHandler(EventType.EQUIP_PERFECT_CHANGE)
    public void handleEquipPerfectChangeEvent(EquipPerfectChangeEvent equipPerfectChangeEvent) {
        Role role = equipPerfectChangeEvent.getRole();
        RoleEquip roleEquip = equipPerfectChangeEvent.getRoleEquip();
        int value = equipPerfectChangeEvent.getPerfect();
        SpringUtils.getBean(EquipRankHandler.class).updatePerfectChange(role, roleEquip, value);
    }

    /**查看跨服排行榜*/
    @RequestMapping
    public void viewCrossRank(IoSession session, ReqCrossRankView reqCrossRankView) {
        Role role = SessionUtils.getRoleBySession(session);
        SpringUtils.getBean(RankService.class).fetch(role, reqCrossRankView.getRankType(), reqCrossRankView.getLevelLimit());
    }

    /**删除宠物更新排行榜*/
    @EventHandler(EventType.REMOVE_PET)
    public void handleRemovePetEvent(RemovePetEvent removePetEvent) {
        Pet pet = removePetEvent.getPet();
        SpringUtils.getBean(PetRankHandler.class).updateAfterRemove(pet);
    }

    /**删除物品更新排行榜*/
    @EventHandler(EventType.REMOVE_ITEM)
    public void handleReomveItemEvent(RemoveItemEvent removeItemEvent) {
        RoleEquip roleEquip = removeItemEvent.getRoleEquip();
        SpringUtils.getBean(EquipRankHandler.class).updateAfterRemove(roleEquip);
    }

    @EventHandler(EventType.PARTY_CAPITAL_CHANGE)
    public void handlePartyCapitalChangeEvent(PartyCapitalChangeEvent partyCapitalChangeEvent) {
        Party party = partyCapitalChangeEvent.getParty();
        /**更新帮派资金排行榜*/
        SpringUtils.getBean(PartyCapitalRankHandler.class).updateRank(party);
    }

    /**pk值改变更新排行榜*/
    @EventHandler(EventType.PK_VALUE_CHANGE)
    public void handlePkValueChangeEvent(PkValueChangeEvent pkValueChangeEvent) {
        Role role = pkValueChangeEvent.getRole();
        SpringUtils.getBean(BullyRankHandler.class).updateRank(role, pkValueChangeEvent.getPkValue());
    }

    /**元婴血婴升级时处理排行榜相关内容*/
    @EventHandler(EventType.CHILD_LEVEL_UP)
    public void handleChildLevelUpEvent(ChildLevelUpEvent childLevelUpEvent) {
        Role role = childLevelUpEvent.getRole();
        if(role.isAi(role)){
            return;
        }
        short level = childLevelUpEvent.getLevel();
        SpringUtils.getBean(ChildLevelRankHandler.class).update(role.getGid(), new ChildLevelRankRecord(role.getGid(), level, role.getPartyName(), role.getName(), role.getPolar()));
    }
}
